<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'tasktable.jsp' starting page</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/1.3.4/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/wu.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/icon.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">

$(function(){
	$('#search').click(function(){
			var min=$('#min').val();
			var max=$('#max').val();
			var tasktype=$("#tasktype").combobox("getValue");
			$("#all").datagrid('load',{
				min:min,
				max:max,
				tasktype:tasktype
			});
		});
		$("#tasktype").combobox({
				url:'${pageContext.request.contextPath}/task?op=tasktypeshow',
				valueField:'id',
				textField:'name',
				panelHeight:'auto'
				});
		$("#all").datagrid({
			url:'${pageContext.request.contextPath}/task?op=taskshowshh',
			 	columns:[[   
		        {field:'id',title:'编号'},   
		        {field:'tasktype',title:'任务名称',width:100,
		        	formatter:function(value,row,index){
		        		return row.userByStartuser.realname+value.name;
		        	}
		        },
		        {field:'userBySenduser',title:'发起时间',width:100,hidden:true,
		        	formatter:function(value,row,index){
		        		return value.realname;
		        	}
		        } ,  
		        {field:'starttime',title:'发起时间',width:100} ,
		        {field:'userByStartuser',title:'申请人',width:100,
		        	formatter:function(value,row,index){
		        		return value.realname;
		        	}
		        },
		        {field:'state',title:'状态',width:100,
		        	formatter:function(value,row,index){
		        			if(value==0){
		        				return "待处理";
		        			}else if(value==1){
		        				return "已处理";
		        			}else if(value==-1){
		        				return "驳回";
		        			}
		        	}
		        },
		        {field:'caozuo',title:'操作',width:100,
		        	formatter:function(value,row,index){
		        	if(row.userByStartuser.realname==($('#loginuser').val())){
		        		return "<a href='${pageContext.request.contextPath}/task?op=taskid&id="+row.id+"'>查看</a>";
		        		}else{
		        		return "<a href='${pageContext.request.contextPath}/task?op=taskid&id="+row.id+"'>审核</a>";
		        		}
		        	}
		        }
		        
		    ]],
			fitColumns : true,
			autoRowHeight : false,
			striped : true,
			loadMsg : '请等待...',
			pagination : true,
			nowrap : true,
			rownumbers : true,
			fit : true,
			singleSelect:true
			});
	
});

function dochack(id){
	var obj = $("#all").datagrid("getSelected");
	$("#taskcheck").window({   
	    width:600,   
	    height:400,   
	    modal:true,
	    title:'审核',
	    iconCls:'icon-edit'
	});
	$.getJSON('task.html?op=TaskById',{taskid:obj.id},function(data){
        $("input[name='shenusers']").val(data.usercar.realname);
		$("input[name='startmits']").val(data.starttime);		
		$("input[name='shentypes']").val(data.tasktype.name);
  		$("input[name='deptusers']").val(data.department.deptname);
  		$("input[name='shenyous']").val(data.content);
  		if(data.tasktype.id==1){
  		$('#divdays').removeAttr("style");
  		$("input[name='holidays']").val(data.content);
  		}
  		if(data.tasktype.id==2){
  		$('#wordcs').removeAttr("style");
  		$('#moneys').removeAttr("style");
  		$("input[name='wordcontens']").val(data.wordconten);
  		$("input[name='usemoneys']").val(data.usemoney);
  		}
  		if(data.tasktype.id==3){
  		$('#others').removeAttr("style");
  		$('#destinats').removeAttr("style");
  		$('#lengthss').removeAttr("style");
  		$("input[name='otherusers']").val(data.otheruser);
  		$("input[name='destinations']").val(data.destination);
  		$("input[name='lengths']").val(data.length);
  		}
  		if(data.tasktype.id==4){
  		$('#shenshis').removeAttr("style");
  		$("input[name='shenshi']").val(data.ordertime);
  		}
  		if(data.tasktype.id==6){
  		$('#phones').removeAttr("style");
  		$('#tels').removeAttr("style");
  		$('#cardnumbers').removeAttr("style");
  		$("input[name='phone']").val(data.phone);
  		$("input[name='tel']").val(data.tel);
  		$("input[name='cardnumber']").val(data.cardnumber);
  		}
	})
	if(obj.state==1 || obj.state==-1){
		$('#dhemuser').val($('#loginuser').val());
		
	}
	if(obj.state==1){
		$('#dhemuserss').val("已处理");
	}else if(obj.state==-1){
		$('#dhemuserss').val("驳回");
	} 
}
function doshen(id){
	var obj = $("#all").datagrid("getSelected");
	$('#taskids').val(obj.id);
	$("#taskallup").window({   
	    width:600,   
	    height:400,   
	    modal:true,
	    title:'审核',
	    iconCls:'icon-edit'
	});
	$.getJSON('task.html?op=TaskById',{taskid:obj.id},function(data){
        $("input[name='shenuser']").val(data.usercar.realname);
		$("input[name='startmit']").val(data.starttime);		
		$("input[name='shentype']").val(data.tasktype.name);
  		$("input[name='deptuser']").val(data.department.deptname);
  		$("input[name='shenyou']").val(data.content);
  		if(data.tasktype.id==1){
  		$('#divday').removeAttr("style");
  		$("input[name='holiday']").val(data.content);
  		}
  		if(data.tasktype.id==2){
  		$('#wordc').removeAttr("style");
  		$('#money').removeAttr("style");
  		$("input[name='wordconten']").val(data.wordconten);
  		$("input[name='usemoney']").val(data.usemoney);
  		}
  		if(data.tasktype.id==3){
  		$('#other').removeAttr("style");
  		$('#destinat').removeAttr("style");
  		$('#lengths').removeAttr("style");
  		$("input[name='otheruser']").val(data.otheruser);
  		$("input[name='destination']").val(data.destination);
  		$("input[name='length']").val(data.length);
  		}
  		if(data.tasktype.id==4){
  		$('#shenshiss').removeAttr("style");
  		$("input[name='shenshis']").val(data.ordertime);
  		}
  		if(data.tasktype.id==6){
  		$('#phoness').removeAttr("style");
  		$('#telss').removeAttr("style");
  		$('#cardnumberss').removeAttr("style");
  		$("input[name='phones']").val(data.phone);
  		$("input[name='tels']").val(data.tel);
  		$("input[name='cardnumbers']").val(data.cardnumber);
  		}
	})
	$('#one').click(function(){
		var one=$(this).val();
		
		var isone=$(this).is(":checked");
		if($(this).get(0).checked){
			$("#nextshens").show();
			
		}
		})
		$('#two').click(function(){
			var isone=$(this).is(":checked");
			if($(this).get(0).checked){
				$("#nextshens").hide();
			}
		})
	
}
$(function(){
	var obj = $("#all").datagrid("getSelected");
	alert(obj.id);

});
</script>
  </head>
  
  <body class="easyui-layout">
  <div data-options="region:'center'" style="padding:5px;background:#eee;">
  				 <input type="hidden" id="loginuser" value="${sys_user.realname }">
	    		<p>发起时间:
	    			<input type="text" id="min" style="width:100px">to
	    			<input type="text" id="max" style="width:100px">
	    		<p>
	    		<p> 任务类型:<input type="text" id="tasktype" style="width:100px"></p>
	    		<a href="javascript:void()" id="search" class="easyui-linkbutton">查询</a> 
  	<table id="all"></table>
  </div>
  		
  <!-- 审批 -->
  <div id="taskallup" style="text-align:center;line-height:30px;padding-top: 10px" >
 	
 	 <div style="float:left">
  		<div>
  		<input type="hidden" id="taskid" name="taskid">
  			<label for="shenuser"> 申请人:</label>&nbsp;&nbsp;
			<input class="easyui-validatebox" type="text" name="shenuser" readonly="readonly"></input>
        </div>  
        <div>
        	<label for="startmit"> 开始时间:</label>
			<input class="easyui-validatebox" type="text" name="startmit" readonly="readonly"></input>
        </div>
        <div>
        	<label for="shentype"> 申请类型:</label>
			<input class="easyui-validatebox" type="text" id="shentype" name="shentype" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="divday">
        	<label for="holiday"> 请假时间:</label>
			<input class="easyui-validatebox" type="text" name="holiday" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="wordc">
        	<label for="wordconten"> 工作任务:</label>
			<input class="easyui-validatebox" type="text" name="wordconten" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="other">
        	<label for="otheruser"> 随行人员:</label>
			<input class="easyui-validatebox" type="text" name="otheruser" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="phoness">
        	<label for="phones"> 手机号:</label>
			<input class="easyui-validatebox" type="text" name="phones" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="telss">
        	<label for="tels"> 座机号:</label>
			<input class="easyui-validatebox" type="text" name="tels" readonly="readonly"></input>
        </div>
        </div>
        <div>
        <div style="display: none;" id="cardnumberss">
        	<label for="cardnumbers"> 数量:</label>
			<input class="easyui-validatebox" type="text" name="cardnumbers" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="money">
        	<label for="usemoney"> 借款金额:</label>
			<input class="easyui-validatebox" type="text" name="usemoney" readonly="readonly"></input>
        </div>
        <div>
        	<label for="deptuser">部门:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input class="easyui-validatebox" type="text" name="deptuser" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="lengths">
        	<label for="length"> 行驶里程:</label>
			<input class="easyui-validatebox" type="text" name="length" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="shenshiss">
        	<label for="shenshi"> 申请时间:</label>
			<input class="easyui-validatebox" type="text" name="shenshis" readonly="readonly"></input>
        </div>
        </div>
        <div style="display: none;" id="destinat">
        	<label for="destination"> 目的地:</label>&nbsp;&nbsp;
			<input class="easyui-validatebox" type="text" name="destination" readonly="readonly"></input>
        </div>
        <div>
        	<label for="shenyou">申请事由:</label>
			<input class="easyui-validatebox" type="text" name="shenyou" readonly="readonly"></input>
        </div>
        <br/>
        <hr/>
         <form action='task.html?op=updtasks' id="updateshen" method="post">
	        <div style="text-align:left">
	        <div>
	        	<label for="shenpi">审批:</label>
	        	<input type="radio" name="one" id="one" value="1">审核通过&nbsp;&nbsp;
	        	<input type="radio" name="one" id="two" value="-1">驳回
	        </div>
	        <div>
	        	<label for="shenpi">审批意见:</label>
	        	<textarea rows="5" cols="50" id="ideal" name="ideal"></textarea>
	        </div>
	         <div style="display: none;" id="nextshens">
	        	<label for="nextshen">审批人:</label>&nbsp;&nbsp;&nbsp;&nbsp;${sys_user.realname }
				
	        </div>
	        </div>
	       <div>
	     	<input type="hidden" id="taskids" name="taskids">
	       
			<input type="submit" value="提交" />
	   </div>
  	 </form>
  </div>
  
  
  
  
  
  
  
  
  
  
  
  <!-- 查看 -->
  <div id="taskcheck" style="text-align:center;line-height:30px;padding-top: 10px" >
  	<div style="float:left">
  		<div>
  			<input type="hidden" id="taskid" name="taskid">
  			<label for="shenusers"> 申请人:</label>&nbsp;&nbsp;
			<input class="easyui-validatebox" type="text" name="shenusers" readonly="readonly"></input>
        </div>  
        <div>
        	<label for="startmits"> 开始时间:</label>
			<input class="easyui-validatebox" type="text" name="startmits" readonly="readonly"></input>
        </div>
        <div>
        	<label for="shentypes"> 申请类型:</label>
			<input class="easyui-validatebox" type="text" id="shentypes" name="shentypes" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="divdays">
        	<label for="holidays"> 请假时间:</label>
			<input class="easyui-validatebox" type="text" name="holidays" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="wordcs">
        	<label for="wordcontens"> 工作任务:</label>
			<input class="easyui-validatebox" type="text" name="wordcontens" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="others">
        	<label for="otherusers"> 随行人员:</label>
			<input class="easyui-validatebox" type="text" name="otherusers" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="phones">
        	<label for="phone"> 手机号:</label>
			<input class="easyui-validatebox" type="text" name="phone" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="tels">
        	<label for="tel"> 座机号:</label>
			<input class="easyui-validatebox" type="text" name="tel" readonly="readonly"></input>
        </div>
        </div>
        <div>
        <div style="display: none;" id="cardnumbers">
        	<label for="cardnumber"> 数量:</label>
			<input class="easyui-validatebox" type="text" name="cardnumber" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="moneys">
        	<label for="usemoneys"> 借款金额:</label>
			<input class="easyui-validatebox" type="text" name="usemoneys" readonly="readonly"></input>
        </div>
        <div>
        	<label for="deptusers">部门:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input class="easyui-validatebox" type="text" name="deptusers" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="lengthss">
        	<label for="lengths"> 行驶里程:</label>
			<input class="easyui-validatebox" type="text" name="lengths" readonly="readonly"></input>
        </div>
        <div style="display: none;" id="shenshis">
        	<label for="shenshi"> 申请时间:</label>
			<input class="easyui-validatebox" type="text" name="shenshi" readonly="readonly"></input>
        </div>
        </div>
        <div style="display: none;" id="destinats">
        	<label for="destinations"> 目的地:</label>&nbsp;&nbsp;
			<input class="easyui-validatebox" type="text" name="destinations" readonly="readonly"></input>
        </div>
        <div>
        	<label for="shenyous">申请事由:</label>
			<input class="easyui-validatebox" type="text" name="shenyous" readonly="readonly"></input>
        </div><br/>
        
        <hr/>
        <div style="text-align:left;font-size:14px">
        	<p>前台记录</p>
        	<p><span>审批人：</span>&nbsp;&nbsp;&nbsp;<span>审批时间：</span>&nbsp;&nbsp;&nbsp;<span>审批信息：</span></p>
        	<p>薪酬专员记录</p>
        	<p><span>审批人：</span>&nbsp;&nbsp;&nbsp;<span>审批结果：</span>&nbsp;&nbsp;&nbsp;<span>审批时间：</span>&nbsp;&nbsp;&nbsp;<span>审批信息：</span></p>
        	<p>部门经理审批</p>
        	<p><span>审批人：</span><input style="width:50px" type="text" id="dhemuser">&nbsp;&nbsp;&nbsp;
        	<span>审批时间：</span><input style="width:50px" type="text" id="dhemusers">&nbsp;&nbsp;&nbsp;
        	<span>审批结果：</span><input style="width:50px" type="text" id="dhemuserss"></p>
        </div>
        
  </div>
  </body>
</html>
